package escritorio.conn;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import escritorio.javaBeans.Prazos;

public class PrazoDao {
	private Connection conn;

	public PrazoDao() {
		super();
		this.conn = new ConnectionFactory().getConnection();
	}

	public void inserePrazo(Prazos prazo) {
		String sql = "insert into prazo " 
	            + "(descricao,dataObj)"
				+ " Values (?,?)";
		try {
			PreparedStatement stmt = conn.prepareStatement(sql);
			stmt.setString(1, prazo.getDescricao());
			stmt.setDate(2, new Date(prazo.getDataObj().getTimeInMillis()));
			stmt.execute();
			stmt.close();
		} catch (SQLException e) {
			throw new ConnErro(null, e);
		}
	}
}
